// 创建store仓库

import { createStore } from 'redux';

type stateType = {
    num: number,
    arr: Array<{
        name: string,
        age: number
    }>
}
const defaultState: stateType = {
    num: 100,
    arr: [{
        name: '张三',
        age: 20
    }]
}

type actionsType = {
    type: string,
    payload?: any
}
const reducer = (state = defaultState, actions: actionsType) => {
    if (actions.type == '+') {
        return {
            ...state,
            num: state.num + actions.payload
        }
    }

    return state
}

const store = createStore(reducer)

export default store